"""
递归算法，实现阶乘
"""

def factorial(num):
    """普通阶乘算法"""
    i = 1
    result = 1
    while i <= num:
        result *= i
        i += 1
    return result

def recursion_actorial(num):
    """使用递归阶乘"""
    if num == 1:
        return num
    return num * recursion_actorial(num -1)

def main():
    """入口函数"""
    num = int(input("计算阶乘，请输入非零数字："))
    result1 = factorial(num)
    result2 = recursion_actorial(num)
    print("%d! = %d"%(num, result1))
    print("%d! = %d"%(num, result2))

main()